//
//  HMBaseNavigationController.m
//  HMDemo
//
//  Created by mengxiangyu on 2017/6/15.
//  Copyright © 2017年 mengxiangyu. All rights reserved.
//

#import "HMBaseNavigationController.h"

@interface HMBaseNavigationController ()

@end

@implementation HMBaseNavigationController

- (instancetype)initWithRootViewController:(UIViewController *)rootViewController
{
    self = [super initWithRootViewController:rootViewController];
    if (self) {
        // 设置导航栏取消黑线
        self.navigationBar.barStyle = UIBarStyleBlack;
        self.navigationBar.barTintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"navigationbarBg"]];
        UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, 44-0.5, HM_WIDTH, 0.5)];
        [self.navigationBar addSubview:line];
        line.backgroundColor = rgba(230, 230, 230, 1);
        
        // 设置title字色
        NSDictionary *dict = @{NSForegroundColorAttributeName : [UIColor darkGrayColor]};
        [self.navigationBar setTitleTextAttributes:dict];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleDefault;
    //UIStatusBarStyleDefault = 0 黑色文字，浅色背景时使用
    //UIStatusBarStyleLightContent = 1 白色文字，深色背景时使用
}

/**
 *  拦截push操作，实现当push出试图控制器时隐藏tabBar
 */
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    
    if (self.viewControllers.count) {// 如果当前控制器堆栈有控制器存在，执行下面这句话
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:animated];
}

@end
